package org.dreamfly.netshop.actions.admin;

import java.util.ArrayList;
import java.util.List;

import org.dreamfly.netshop.entity.Admin;
import org.dreamfly.netshop.entity.OrderInfo;
import org.dreamfly.netshop.entity.Type;
import org.dreamfly.netshop.manage.OrderInfoManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 用户管理Action. 使用Struts2 convention-plugin annotation定义Action参数.
 * 
 * @author calvin
 */
public class MemberAction extends ActionSupport {

//    @Autowired
//    private ClassManager classManager;
//
//    @Autowired
//    private GoodsInfoManager goodsInfoManager;

    @Autowired
    private OrderInfoManager orderInfoManager;

    private List<Type> allClass;

    private String type;

    private Admin admin;

    private Page<OrderInfo> orderInfoP = new Page<OrderInfo>(20);

    private List<OrderInfo> orderInfoL = new ArrayList<OrderInfo>(4);

    public List<Type> getAllClass() {
        return allClass;
    }

    public Admin getAdmin() {
        return admin;
    }

    public void setAdmin(Admin admin) {
        this.admin = admin;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Page<OrderInfo> getOrderInfoP() {
        return orderInfoP;
    }

    public void setOrderInfoP(Page<OrderInfo> orderInfoP) {
        this.orderInfoP = orderInfoP;
    }

    public List<OrderInfo> getOrderInfoL() {
        return orderInfoL;
    }

    public void setOrderInfoL(List<OrderInfo> orderInfoL) {
        this.orderInfoL = orderInfoL;
    }

    @Override
    public String execute() {
        // ActionContext ctx = ActionContext.getContext();
        // HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
        // HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
        // classManager.delete((long) 21);
        return SUCCESS;
    }

    public String search() {
        return SUCCESS;
    }

    public String getByConfirm() {
        orderInfoP = orderInfoManager.getByConfirm("true".equals(type) ? true : false, orderInfoP);
        return SUCCESS;
    }

    public String getByPayment() {
        orderInfoP = orderInfoManager.getByConfirm("true".equals(type) ? true : false, orderInfoP);
        return SUCCESS;
    }

    public String getByConsignment() {
        orderInfoP = orderInfoManager.getByConfirm("true".equals(type) ? true : false, orderInfoP);
        return SUCCESS;
    }
}
